#pragma once

class CItemSizeManager
{
public:
	// Anchor
	static const DWORD	ANCHOR_TOP			= 0x01;
	static const DWORD	ANCHOR_LEFT			= 0x02;
	static const DWORD	ANCHOR_RIGHT		= 0x04;
	static const DWORD	ANCHOR_BOTTOM		= 0x08;
	static const DWORD	ANCHOR_TOP_LEFT		= ANCHOR_LEFT | ANCHOR_TOP;
	static const DWORD	ANCHOR_BOTTOM_RIGHT	= ANCHOR_RIGHT | ANCHOR_BOTTOM;
	static const DWORD	ANCHOR_ALL			= ANCHOR_TOP_LEFT | ANCHOR_BOTTOM_RIGHT;

protected:
	// Item information node structure
	typedef struct tagItemLinkNode
	{
		UINT	Id;
		DWORD	Anchor;
		POINT	LeftTop;
		SIZE	Size;
		tagItemLinkNode *	pNext;
	}
	ITEM_LINEK_NODE, FAR * LP_ITEM_LINEK_NODE;

protected:
	ITEM_LINEK_NODE	m_ItemLinkHead;

protected:
	// Converts the screen coordinates of a specified rect on the screen to client-area coordinates. 
	BOOL static ScreenToClientRect(HWND hWnd, RECT & Rect);
	// Converts the client-area coordinates of a specified point to screen coordinates.
	BOOL static ClientToScreenRect(HWND hWnd, RECT & Rect);

public:
	CItemSizeManager(void);
	virtual ~CItemSizeManager(void);

	// Add Item and it's resize style that need processed by this class
	BOOL AddItem(UINT ItemId, DWORD dwAnchor);
	// Initialize item's position information
	BOOL Initialize(HWND hWnd);
	// UnInitialize
	void UnInitialize(void);
	// Resize items when container window's size is changed
	void OnSize(HWND hWnd, SIZE &WndSize);
};
